home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
051-075
/
disk_066
/
foogol
/
test.s.reference
< prev
Wrap
Text File
|
1992-05-06
|
2KB
|
163 lines
.text # # begin
.align 1
.globl _main
_main:
.word 0
.data 1 # integer
n: .long 0
div: .long 0
sub: .long 0
test: .long 0
testcopy: .long 0
found: .long 0
max: .long 0
.text
movl $2,r0
movl r0,test # test:=
movl $10,r0
movl r0,max # max:=
L0: # # # while
movl n,r0
pushl r0 # <>
movl max,r0
cmpl (sp)+,r0
beql L3
movl $1,r0
jmp L4
L3: movl $0,r0
L4:
tstl r0
bneq L2
jmp L1
L2: # # # do
# # # begin
movl test,r0
pushl r0 # -term
movl $1,r0
subl3 r0,(sp)+,r0
movl r0,div # div:=
movl $0,r0
movl r0,found # found:=
L5: # # # while
movl div,r0
pushl r0 # -term
movl $1,r0
subl3 r0,(sp)+,r0
tstl r0
bneq L7
jmp L6
L7: # # # do
# # # begin
movl test,r0
movl r0,testcopy # testcopy:=
movl $0,r0
movl r0,sub # sub:=
L8: # # # while
movl testcopy,r0
tstl r0
bneq L10
jmp L9
L10: # # # do
# # # begin
movl sub,r0
pushl r0 # +term
movl $1,r0
addl2 (sp)+,r0
movl r0,sub # sub:=
movl sub,r0
pushl r0 # =
movl div,r0
cmpl (sp)+,r0
beql L14
movl $0,r0
jmp L15
L14: movl $1,r0
L15:
tstl r0 # if
bneq L13 # then
jmp L12
L13:
movl $0,r0
movl r0,sub # sub:=
jmp L11
L12: # # # else
L11: # # # endif
movl testcopy,r0
pushl r0 # -term
movl $1,r0
subl3 r0,(sp)+,r0
movl r0,testcopy # testcopy:=
# # # end
jmp L8
L9: # # # endwhile
movl sub,r0
pushl r0 # =
movl $0,r0
cmpl (sp)+,r0
beql L19
movl $0,r0
jmp L20
L19: movl $1,r0
L20:
tstl r0 # if
bneq L18 # then
jmp L17
L18:
movl $1,r0
movl r0,found # found:=
jmp L16
L17: # # # else
L16: # # # endif
movl div,r0
pushl r0 # -term
movl $1,r0
subl3 r0,(sp)+,r0
movl r0,div # div:=
# # # end
jmp L5
L6: # # # endwhile
movl found,r0
pushl r0 # =
movl $0,r0
cmpl (sp)+,r0
beql L24
movl $0,r0
jmp L25
L24: movl $1,r0
L25:
tstl r0 # if
bneq L23 # then
jmp L22
L23:
# # # begin
movl n,r0
pushl r0 # +term
movl $1,r0
addl2 (sp)+,r0
movl r0,n # n:=
movl test,r0
pushl r0 # printn
calls $1,_PRN
.data 1 # prints
L26: .asciz " is prime number "
.text
pushal L26
calls $1,_PRS
movl n,r0
pushl r0 # printn
calls $1,_PRN
calls $0,_PR # print
# # # end
jmp L21
L22: # # # else
L21: # # # endif
movl test,r0
pushl r0 # +term
movl $1,r0
addl2 (sp)+,r0
movl r0,test # test:=
# # # end
jmp L0
L1: # # # endwhile
ret # # end